/**
 * Copyright (c) 2015-2020, wss 王山山
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.wss.conversion.config;

import com.wss.utils.StringUtil;

/**
 * 数据库配置
 * 
 * @author wss
 *
 */
public class Database {
	private String driverClass;
	private String url;
	private String user;
	private String password;
	
	/*
	 * 数据库连接池中的最大连接数
	 */
	private int maxPoolSize = 100;
	/*
	 * 数据库连接池中的最小连接数
	 */
	private int minPoolSize = 10;
	/*
	 * 数据库连接池中的初始连接数
	 */
	private int initialPoolSize = 10;
	/*
	 * 数据库连接的最大空闲时间
	 */
	private int maxIdleTime = 20;
	/*
	 * 当数据库中连接数不足时，一次获得的连接数量 
	 */
	private int acquireIncrement = 2;
	
	public Database() {}

	public Database(String driverClass, String url, String user, String password) {
		super();
		this.driverClass = driverClass;
		this.url = url;
		this.user = user;
		this.password = password;
	}

	public String getDriverClass() {
		return driverClass;
	}

	public void setDriverClass(String driverClass) {
		this.driverClass = driverClass;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	public int getMaxPoolSize() {
		return maxPoolSize;
	}

	public void setMaxPoolSize(int maxPoolSize) {
		this.maxPoolSize = maxPoolSize;
	}

	public int getMinPoolSize() {
		return minPoolSize;
	}

	public void setMinPoolSize(int minPoolSize) {
		this.minPoolSize = minPoolSize;
	}

	public int getInitialPoolSize() {
		return initialPoolSize;
	}

	public void setInitialPoolSize(int initialPoolSize) {
		this.initialPoolSize = initialPoolSize;
	}

	public int getMaxIdleTime() {
		return maxIdleTime;
	}

	public void setMaxIdleTime(int maxIdleTime) {
		this.maxIdleTime = maxIdleTime;
	}

	public int getAcquireIncrement() {
		return acquireIncrement;
	}

	public void setAcquireIncrement(int acquireIncrement) {
		this.acquireIncrement = acquireIncrement;
	}

	public boolean isAviable() {
		return StringUtil.isNotBlank(driverClass)
				&& StringUtil.isNotBlank(url)
				&& StringUtil.isNotBlank(user)
				&& StringUtil.isNotBlank(password);
	}

	@Override
	public String toString() {
		return "Database [driverClass=" + driverClass + ", url=" + url + ", user=" + user + ", password=" + password
				+ ", maxPoolSize=" + maxPoolSize + ", minPoolSize=" + minPoolSize + ", initialPoolSize="
				+ initialPoolSize + ", maxIdleTime=" + maxIdleTime + ", acquireIncrement=" + acquireIncrement
				+ "]";
	}
}
